import { fileURLToPath, URL } from 'node:url'
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// @ts-ignore
import ElementPlus from 'unplugin-element-plus/vite'
// @ts-ignore
// 需在tsconfig.json文件，compilerOptions配置项中添加"types": ["unplugin-vue-define-options/macros-global"]，解除ts报错
import DefineOptions from 'unplugin-vue-define-options/vite'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    ElementPlus(),
    DefineOptions(),
    createSvgIconsPlugin({
      // Specify the icon folder to be cached
      iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
      // Specify symbolId format
      symbolId: 'icon-[dir]-[name]'
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      '@basicComp': fileURLToPath(new URL('./src/components/basic', import.meta.url)),
      '@bussComp': fileURLToPath(new URL('./src/components/bussiness', import.meta.url)),
      '@Itypes': fileURLToPath(new URL('./src/commonTypes', import.meta.url))
    }
  },
  server: {
    host: '0.0.0.0',
    port: 5174,
    open: true
    // proxy: {
    //   "/scdeap": {
    //     target: "http://61.129.71.53:9190",
    //     rewrite: (path) => path.replace(/^\/scdeap/, "/scdeap"),
    //   },
    // },
  }
})
